<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="../../common/sessionValidate.jsp" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
<head>
    <title>我的待办任务</title>
    <%@ include file="../../common/meta.jsp"%>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <link rel="stylesheet" href="<%=basePath%>css/my-bootstrap.css" media="screen"  id="tuserskin">
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <script type="text/javascript" src="<%= basePath %>js/jquery.cookie.js"></script>
</head>
<style>
    hr {
        margin-top:1px;
        border-bottom: 1px solid #1BBC9B;
    }
</style>
<body>
<div class="" style="margin-right:2px;padding-right:1px;">

    <!--------------------------查询条件表格  start------------------------------->
    <form class="form-horizontal" name="form1" id="form1">
        <!-- 查询面板 -->
        <div class="panel panel-primary" id="cxDiv">
            <!-- Default panel contents -->
            <div class="panel-heading  " >
                <i class='icon-filter'></i>&nbsp;我的待办任务
                <span class="text-right pull-right">
        	<button type="button" class=" btn btn-success btn-xs img-rounded"  onclick="Search(0)"><i class="icon-search"></i>&nbsp;查询</button>&nbsp;
            <button type="reset" class=" btn btn-success btn-xs img-rounded"  > <span class="icon-retweet"></span>&nbsp;重置</button>&nbsp;
            <button type="button" class=" btn btn-success btn-xs img-rounded" id="shButton" >&nbsp;<span id="qhDiv" class="icon-chevron-up"></span>&nbsp;</button>
            <input type="hidden" name="process_code" id="process_code" value="SixProcess">
        </span>
            </div>
            <div class="panel-body" id="shDiv" class="panel-collapse collapse in">
                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-5">申请编号</label>
                        <div class="col-xs-7">
                            <input name="appid" type="text" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-5">开始时间</label>
                        <div class="col-xs-7">
                            <input name="startdate" id="startdate" type="text" class="form-control" onclick='SelectDate(this)' readonly='true'>
                        </div>
                    </div>
                </div>
                <div class="col-xs-3 ">
                    <div class="form-group">
                        <label class="control-label col-xs-5">截止时间</label>
                        <div class="col-xs-7">
                            <input name="enddate" id="enddate" type="text" class="form-control" onclick='SelectDate(this)' readonly='true'>
                            <input name="tninstancestatus" type="hidden" class="form-control" value="0" >
                        </div>
                    </div>
                </div>
                <!--
                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-6"> 状态</label>
                        <div class="col-xs-6">
                            <input name="showtninstancestatus" type="text" class="form-control" value="待审核" readonly>
                            <input name="tninstancestatus" type="hidden" class="form-control" value="0" >
                        </div>
                    </div>
                </div>-->
                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-5">流程节点实例id</label>
                        <div class="col-xs-7">
                            <input name="tninstanceid" type="text" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-6"> 申请人</label>
                        <div class="col-xs-6">
                            <input name="creater" type="text" class="form-control">
                        </div>
                    </div>
                </div>

                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-6"> 流程名称</label>
                        <div class="col-xs-6">
                            <input name="firststep" type="text" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-xs-3">
                    <div class="form-group">
                        <label class="control-label col-xs-6"> 节点名称</label>
                        <div class="col-xs-6">
                            <input name="laststep" type="text" class="form-control">
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </form>
    <!--------------------------查询条件表格end------------------------------------->

    <!--------------------------信息列表：带表格面板  start--------------------------------->
    <div class="panel panel-primary">
        <div class="panel-heading clearfix" >
            <i class='icon-reorder'></i>&nbsp; 我的待办任务列表
            <span class="text-right pull-right ">
            </span>
        </div>
        <div class="panel-body">
            <p>每页显示<select id="pageSize" class=" label-primary" onchange="Search(0)">
                <option value="5" >5</option>
                <option value="10" >10</option>
                <option value="20">20</option>
                <option value="30">30</option>
                <option value="50">50</option>
            </select>条记录，&nbsp;&nbsp;&nbsp;&nbsp;共有记录：<span id="totalCount" class="label label-primary">0</span> 条，总页数：<span id="totalPageNo" class="label label-primary">0</span>页。
            </p>
            <table id="grid" class="table table-condensed table-striped table-bordered table-hover" class="sortable" cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                <thead id="grid_head">
                <tr>
                    <th onclick="" class="table-checkbox" ><input class="group-checkable" name="batchSelectedAll" id="batchSelectedAll" type="checkbox" onclick="selectAll()"></th>
                    <!--
                    <th onclick="sortTableT.sort('grid',0,'String')"> 流程节点实例编号</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 流程实例id</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 节点步骤</th>
                    -->
                    <th onclick="sortTableT.sort('grid',0,'String')"> 申请编号</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 流程id-名称</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 节点id-名称</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 节点步骤</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 待审核人</th>

                    <th onclick="sortTableT.sort('grid',0,'String')"> 申请人</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 发起时间</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 流程实例id</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 流程节点实例id</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 审核状态</th>
                    <!--
                    <th onclick="sortTableT.sort('grid',0,'String')"> 更新人</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> 更新时间</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> note</th>
                    <th onclick="sortTableT.sort('grid',0,'String')"> roleid</th>
                    <th onclick="sortTableT.sort('grid',0,'String')">流程状态</th>-->
                    <th style="width:150px">操作</th>
                </tr>
                </thead>
                <tbody id="grid_body"></tbody>
            </table>
            <div class="paging-toolbar">
                <ul class="pager" style='margin-bottom:5px;' id='grid_paging'></ul>
            </div>
        </div>
    </div>
    <!--------------------------信息列表：带表格面板 end------------------------------------>

</div>
</body>
</html>

<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!--<script src="<%=basePath%>js/jquery-1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrapValidator.js"></script>-->
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
<!-- <script src="<%=basePath%>js/additional-methods.min.js"></script> -->
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%= basePath %>js/tableSortTool.js" ></script>
<script src="<%= basePath %>js/calendar.js" ></script>

<script type="text/javascript">
    $().ready(function(){
        //1、初始化数据显示
        Search(0);

        //2、隐藏或者显示
        $("#shButton").click(function(){
            $("#shDiv").toggle();
            $("#qhDiv").toggleClass("icon-chevron-up icon-chevron-down");
        });

    }) //end funciton read;

    //根据查询条件，查询列表数据并显示
    function Search(startIndex){
        var pageSize = document.getElementById("pageSize").value;
        var condition = $("#form1").serialize();
        var url = "<%=basePath%>workflow/getTaskNodeInstanceList?startIndex="+startIndex+"&pageSize="+pageSize+"&"+condition+"&time="+Math.random();
        //alert(url);
        $.getJSON(url, function (data){
            //$("#pageSize").html(data.pageSize);
            $("#totalCount").html(data.totalCount);
            $("#totalPageNo").html(data.totalPageNo);
            $("#grid_body").html("");

            //1、表格行内容输出
            $.each(data.items, function(i,item){
                var str="<tr>";
                str+="<td><input class='checkboxes' name='batchSelected' id='batchSelected' type='checkbox' value='"+item.tninstanceid+"'></td>";
                str+="<td>"+doNull(item.appid)+"</td>";
                str+="<td>"+doNull(item.taskid)+"-"+doNull(item.firststep)+"</td>";
                str+="<td>"+doNull(item.nodeid)+"-"+doNull(item.laststep)+"</td>";
                str+="<td>"+doNull(item.nodestep)+"</td>";
                str+="<td>"+doNull(item.userid)+"</td>";

                //str+="<td>"+doNull(item.creater)+"</td>";
                //str+="<td>"+doNull(item.createtime)+"</td>";
                str+="<td>"+doNull(item.memo1)+"</td>";
                str+="<td>"+doNull(item.memo2)+"</td>";
                //str+="<td>"+doNull(item.instanceid)+"</td>";
                str+="<td>"+doNull(item.instanceid)+"</td>";
                str+="<td>"+doNull(item.tninstanceid)+"</td>";
                //str+="<td>"+doNull(item.tninstancestatus)+"</td>";
                if(item.tninstancestatus==0){
                	str+="<td><span class='label label-success'>待审核</span></td>";
                }else if(item.tninstancestatus==1) {
                    str += "<td><span class='label label-success'>已结束</span></td>";
                }else if(item.tninstancestatus==2){
                        str+="<td><span class='label label-danger'>已退回</span></td>";
                }else{
                	str+="<td><span class='label label-danger'>其它</span></td>";
                }
                str+="<td>&nbsp;&nbsp;";
                //str+="<a href='<%=basePath%>t_task_node_instance/toT_task_node_instanceCurd?oplx=view&id="+item.tninstanceid+"' class='text-danger'>&nbsp;&nbsp;<span class='glyphicon glyphicon-search' style='color:rgb(0, 128, 255)'></span>&nbsp;&nbsp;</a>";
                //str+="<a href='<%=basePath%>t_task_node_instance/toT_task_node_instanceCurd?oplx=edit&id="+item.tninstanceid+"' class='text-danger'>&nbsp;&nbsp;<span class='icon-pencil'  style='color:rgb(0, 128, 255)'></span>&nbsp;&nbsp;</a>";
                //str+="<a href='javascript:del("+item.tninstanceid+")' class='text-danger'>&nbsp;&nbsp;<span class='icon-remove' style='color:rgb(0, 128, 255)'></span></a>&nbsp;&nbsp;";
                //if(item.process_status==null||item.process_status==""){

                //去不同的审核页面
                var toUrl ="";
                if(doNull(item.biztype)=="ContractApply"){
                    toUrl = "t_news/toT_newsContractSH";
                }else if(doNull(item.biztype)=="MoneyApply"){
                    toUrl = "t_news/toT_newsMoneySH";
                }else if(doNull(item.biztype)=="PayApply"){
                    toUrl = "t_news/toT_newsPaySH";
                }else if(doNull(item.biztype)=="YongyinApply"){
                    toUrl = "t_news/toT_newsYongyinSH";
                }else if(doNull(item.biztype)=="FawenApply"){
                    toUrl = "t_news/toT_newsFawenSH";
                }else if(doNull(item.biztype)=="ReceiveApply"){
                    toUrl = "t_news/toT_newsReceiveSH";
                }else if(doNull(item.biztype)=="GetApply"){
                    toUrl = "t_news/toT_newsGetSH";
                }else if(doNull(item.biztype)=="CarApply"){
                    toUrl = "t_news/toT_newsCarSH";
                }else if(doNull(item.biztype)=="HolidyApply"){
                    toUrl = "t_news/toT_newsHolidySH";
                }else if(doNull(item.biztype)=="OutApply"){
                    toUrl = "t_news/toT_newsOutSH";
                }else if(doNull(item.biztype)=="TrivalApply"){
                    toUrl = "t_news/toT_newsTrivalSH";
                }else if(doNull(item.biztype)=="AddjobApply"){
                    toUrl = "t_news/toT_newsAddjobSH";
                }else if(doNull(item.biztype)=="AddcardApply"){
                    toUrl = "t_news/toT_newsAddcardSH";
                }else if(doNull(item.biztype)=="KuaidiApply"){
                    toUrl = "t_news/toT_newsCurdKuaidiSH";
                }else if(doNull(item.biztype)=="MyApply"){
                    toUrl = "t_company/toT_companyCurdSH";
                }else if(doNull(item.biztype)=="CgsqApply"){
                    toUrl = "t_news/toT_newsCgsqSH";
                }else{
                    toUrl = "t_demo/toT_demoCurdSH";
                }
                //alert("item.biztype="+item.biztype+";toUrl="+toUrl);
                str+="<a href='<%=basePath%>"+toUrl+"?oplx=check&appid="+item.appid+"&tninstanceid="+item.tninstanceid+"&instanceid="+item.instanceid+"&biztype="+item.biztype+"&taskid="+item.taskid+"'  title=''><span  class='label label-success'>审核</span></a>&nbsp;&nbsp;";
                //}
                str+="</td>";
                str+="</tr>";
                $("#grid_body").append(str);
            });//end each data;

            //2、分业处理
            var element = $("#grid_paging");
            if(data.totalCount>0){
                //第二种处理分页方案，直接生成分页html内容，然后.html()到目标对象；
                var pageHtml ="";
                pageHtml +='<li><button type="button" class=" btn btn-primary btn-sm " onclick="Search('+data.firstIndex+')">首页</button></li>';
                pageHtml +='<li><button type="button" class=" btn btn-primary btn-sm " onclick="Search('+data.previousIndex+')">上一页</button></li>';
                pageHtml +='<li><button type="button" class=" btn btn-primary btn-sm " >当前第  '+data.currentPageNo+' 页</button></li>';
                pageHtml +='<li><button type="button" class=" btn btn-primary btn-sm " onclick="Search('+data.nextIndex+')">下一页</button></li>';
                pageHtml +='<li><button type="button" class=" btn btn-primary btn-sm " onclick="Search('+data.lastIndex+')">尾页</button></li>';
                element.html(pageHtml);
            }else{
                element.html("");
            }
        })//end getJSON;
    }

</script>
